import "crvpuppet"

define at3_ntpserver($webaddr="", $roleid="") {
  if $AutoMode==true and $CloudCRV==true {
  }
  
  if ( $AutoMode == false ) or ( $AutoMode==true and $CloudCRV==true ) {
    package { "ntp":
      ensure => installed,
    }

    notice("$ntpserver_subnetaddr $ntpserver_subnetmask")

#    exec { runntpdate:
#      command => "ntpdate -u $ntpserver_ntpserver"
#    }
  
    file { "/etc/ntp.conf":
      owner => "root",
      group => "root",
      mode => 644,
      content => template("at3_ntpserver/etc-ntp.conf"),
      notify => Service["ntpd"],
    }
    
    service { "ntpd":
      hasstatus => true,
      hasrestart => true,
      ensure => running,
      enable => true,
      require => [Package["ntp"],File["/etc/ntp.conf"]],
    }
  }
  
  if $AutoMode==true and $CloudCRV==true {
    set_role_attr($webaddr,$roleid,"ProfileApplied","True")
  }
}

define at3_ntpserver_reverse($webaddr, $roleid) {
  set_role_attr($webaddr,$roleid,"ReverseProfileApplied","True")
}

